
var examples = [];

(function (){
    var example = { 
        name : "using regex to compare a string with multiple values",
        code : function (){

                ok( (/^(admin|poweruser)/i).test("Admin"), "compare ignore case");
                ok( !(/^(admin|poweruser)/i).test(null), "compare to 'null' case");
            }
    };
    examples.push(example); //comment this line to remove from the test
})();    

(function(){
    var example = { 
        name : "protecting from 'null' and 'undefined' values with string operations",
        code : function (){
                
                var colorsText = "blue, red, green";
                ok( -1 < colorsText.indexOf("red"), "contains 'red'");
                

                throws( function (){ 
                            var nullText = null;
                            return nullText.indexOf("red") > -1; 
                        },
                        "throws an exception");

                var nullText = null;
                ok( !( -1 < (""+nullText).indexOf("red") ), "does not contain 'red'");
                ok( !( -1 < (nullText||"").indexOf("red") ), "does not contain 'red'");

                var undefinedText = undefined;
                ok( !( -1 < (""+undefinedText).indexOf("red") ), "does not contain 'red'");
                ok( !( -1 < (undefinedText||"").indexOf("red") ), "does not contain 'red'");
            }
    };
    examples.push(example); //comment this line to remove from the test
})();    

